/************************************************************************

								Heroes IV
					  Copyright 2000, The 3DO Company

	------------------------------------------------------------------
  							 script_logical_expression.h

	$Header: /heroes4/script_logical_expression.h $

	$NoKeywords: $

 ************************************************************************/

#if !defined( SCRIPT_LOGICAL_EXPRESSION_H_INCLUDED )
#define SCRIPT_LOGICAL_EXPRESSION_H_INCLUDED

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

#include "abstract_script_expression.h"
#include "script_compound_expression.h"
#include "script_expression_type.h"

// --------------------------------------------------------------------------
// t_script_unary_logical_expression class
// --------------------------------------------------------------------------

class t_script_unary_logical_expression
	:	public t_script_unary_expression<
					t_abstract_script_boolean_expression,
					t_abstract_script_boolean_expression >
{
public:
	virtual t_result	evaluate(t_expression_context_hero const& context) const;
	virtual t_result	evaluate(t_expression_context_town const& context) const;
	virtual t_result	evaluate(t_expression_context_object const& context) const;
	virtual t_result	evaluate(t_expression_context_army const& context) const;
	virtual t_result	evaluate(t_expression_context_global const& context) const;

protected:
	virtual t_result	do_evaluation(t_result arg) const = 0;
};

class t_script_expression_not 
	: public t_script_unary_logical_expression
{
protected:
	virtual t_result	do_evaluation(t_result arg) const;
};

SPECIALIZE_SCRIPT_BOOLEAN_EXPRESSION( k_script_boolean_not, t_script_expression_not );

// --------------------------------------------------------------------------
// t_script_binary_logical_expression class
// --------------------------------------------------------------------------

class t_script_binary_logical_expression
	:	public	t_script_binary_expression<
					t_abstract_script_boolean_expression,
					t_abstract_script_boolean_expression >
{
public:
	virtual t_result	evaluate(t_expression_context_hero const& context) const;
	virtual t_result	evaluate(t_expression_context_town const& context) const;
	virtual t_result	evaluate(t_expression_context_object const& context) const;
	virtual t_result	evaluate(t_expression_context_army const& context) const;
	virtual t_result	evaluate(t_expression_context_global const& context) const;

protected:
	virtual t_result	do_evaluation(t_result left, t_result right) const = 0;
};

class t_script_expression_or
	:	public t_script_binary_logical_expression
{
protected:
	virtual t_result	do_evaluation(t_result left, t_result right) const;
};
	
class t_script_expression_and
	:	public t_script_binary_logical_expression
{
protected:
	virtual t_result	do_evaluation(t_result left, t_result right) const;
};
	
SPECIALIZE_SCRIPT_BOOLEAN_EXPRESSION( k_script_boolean_and, t_script_expression_and );
SPECIALIZE_SCRIPT_BOOLEAN_EXPRESSION( k_script_boolean_or, t_script_expression_or );

#endif // !defined( SCRIPT_LOGICAL_EXPRESSION_H_INCLUDED )
